package com.whfc.base.manager.impl;

import com.whfc.base.manager.SmsMgr;
import com.whfc.common.enums.PhoneType;
import com.whfc.common.third.sms.SmsApi;
import com.whfc.common.util.RegexUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2021-10-13 17:10
 */
@Component
public class SmsMgrImpl implements SmsMgr {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 中国大陆-短信服务API
     */
    @Resource(name = "baseSmsApi")
    private SmsApi baseSmsApi;

    /**
     * 港澳台-短信服务API
     */
    @Resource(name = "hmtSmsApi")
    private SmsApi hmtSmsApi;

    @Override
    public SmsApi SmsApi(String phone) {
        PhoneType phoneType = RegexUtil.getPhoneType(phone);
        if (PhoneType.HMT.equals(phoneType)) {
            return hmtSmsApi;
        }
        return baseSmsApi;
    }
}
